package com.ywu.application.standard.thirdExec.exec.param.iml;

import com.ywu.common.gson.GsonUtils;
import com.ywu.application.standard.thirdExec.entity.YwuThirdExecParamEntity;
import com.ywu.application.standard.thirdExec.exec.param.YwuExecParamParse;
import org.springframework.stereotype.Component;

/**
 * @ClassName YwuExecParamParseString
 * @Description TODO
 * @Author GroundDemo
 * @Date 2024/10/16 8:53
 * @Version 1.0
 **/
@Component
public class YwuExecParamParseString implements YwuExecParamParse {

    private static final String STRING_PARAM_TYPE = "string";

    /**
    * @Author GroundDemo
    * @Description 参数类型
    * @Date 9:04 2024/10/16
    * @Param []
    * @return java.lang.String
    **/
    @Override
    public String paramType() {
        return STRING_PARAM_TYPE;
    }

    /**
    * @Author GroundDemo
    * @Description 参数转换
    * @Date 9:04 2024/10/16
    * @Param [entity]
    * @return java.lang.Object
    **/
    @Override
    public Object parse(YwuThirdExecParamEntity entity) {
        if (entity.getIsArray()) {
            return GsonUtils.deserializeList(entity.getValue(), String.class);
        } else {
            return entity.getValue();
        }
    }
}
